package n09.first;

import java.util.Arrays;
import java.util.Comparator;

import n09.first.Person.SortBy;

public class F01 {

	public static void main(String[] args) {
		Student[]students= new Student[] {
			new Student("Zhangsan", 20, "ShuiHuan"),
			new Student("Lisi", 21, "ZhengDa"),
			new Student("Wangwu", 22, "HeDa"),
		};
		System.out.println("Student[]按Name进行排序：");
		Arrays.sort(students, Person.sortBy(SortBy.Name));
		for (Student student : students) {
			System.out.println("    "+student);
		}
		System.out.println("Student[]按Age进行排序：");
		Arrays.sort(students, Person.sortBy(SortBy.Age));
		for (Student student : students) {
			System.out.println("    "+student);
		}
		System.out.println("Student[]按School进行升序排序：");
		Arrays.sort(students, (s1,s2)->s1.getSchool().compareTo(s2.getSchool()));
		for (Student student : students) {
			System.out.println("    "+student);
		}
		System.out.println("Student[]按School进行降序排序：");
		Arrays.sort(students, ((Comparator<Student>)(s1,s2)->s1.getSchool().compareTo(s2.getSchool())).reversed());
		for (Student student : students) {
			System.out.println("    "+student);
		}
	}

}
